home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 36
/
PC Gamer IT CD 36 2-2.iso
/
VIGDEMO
/
data1.cab
/
Assets
/
scripts
/
spawn.e
< prev
next >
Wrap
Text File
|
1998-09-21
|
4KB
|
667 lines
int Initialize(string type) {
global real respawnTime = 20.0;
global real pollInterval = 5.0;
global int mystate = 0;
global int gObjectCount;
global int gMaxObject = -1;
global string spawntype = "amr50snp";
global string gAddToTuple = "";
global int gStartSound = 45;
global int gProgressSound = -1;
global int gEndSound = -1;
global int gMsgSnd = -1;
global real gStartDelay = 0.2;
global int gWantToStart = 0;
global int gOneTime = 0;
global int gTurnOff = 0;
Reset("dummy");
}
int Reset(string dummy)
{
real time;
if (gWantToStart != 1)
mystate = 0;
SetCollidableProperties(thisObject,1,0);
SetStyle(thisObject,5);
gTurnOff = 0;
time = 0.0;
wakeupTime = time + gStartDelay;
}
int addproperty(string addString)
{
gAddToTuple = AppendString(gAddToTuple, addString);
gAddToTuple = AppendString(gAddToTuple, "\r");
}
int startdelay(string addString)
{
gStartDelay = Str2Real(addString);
}
int startsound(string soundname)
{
gStartSound = GetSoundIndex(soundname);
}
int endsound(string soundname)
{
gEndSound = GetSoundIndex(soundname);
}
int progresssound(string soundname)
{
gProgressSound = GetSoundIndex(soundname);
}
int type(string theType) {
spawntype = theType;
}
int spawntime(string str) {
respawnTime = Str2Real(str);
}
int max(string str)
{
gMaxObject = Str2Int(str);
}
int onetime(string dummy)
{
gOneTime = 1;
}
int start(string msg)
{
if (gTurnOff == 0)
{
if (gOneTime == 1)
gTurnOff = 1;
gWantToStart = 1;
if (mystate == 0)
{
mystate = 1;
gObjectCount = 0;
wakeupTime = GetTime(thisObject) + gStartDelay;
}
}
}
int msgsnd(string soundname)
{
gMsgSnd = GetSoundIndex(soundname);
}
int TimedEvent(int input)
{
real time;
int result;
map::iterator ix;
map::iterator iy;
map objInList;
time = GetTime(thisObject);
switch (mystate)
{
case 0:
wakeupTime = -1.0;
break;
case 1:
result = IsAuthoritative(thisObject);
if (result == 1)
{
int doSpawn = 0;
if (gMaxObject == -1)
doSpawn = 1;
else if (gMaxObject > gObjectCount)
doSpawn = 1;
if (doSpawn == 1)
{
CreateObject( spawntype, gAddToTuple);
gObjectCount = gObjectCount + 1;
IsFlag(thisObject,gObjectCount);
PlaySound(thisObject,gStartSound);
PlaySound(thisObject,gMsgSnd);
SendEnglishMessage(thisObject);
mystate = 2;
wakeupTime = time + pollInterval;
}
else
{
mystate = 0;
wakeupTime = -1.0;
}
}
break;
case 2:
result = IsAuthoritative(thisObject);
if (result == 1)
{
objInList = Collisions(thisObject,1,0,0);
ix = begin(objInList);
iy = end(objInList);
if (ix == iy)
{
mystate = 1;
wakeupTime = time + respawnTime;
}
else
wakeupTime = time + pollInterval;
}
break;
default:
break;
}
return 0;
}